import { queryProductList } from "@src/api/points";
import router from "@src/router";

Component({
  options: {
    addGlobalClass: true
  },
  behaviors: [router.routerBehavior],
  data: {
    listData: [],
    isHasData: [],
    hasNextPage: false,
  },
  lifetimes: {
    attached: function () {
      this.fetchData()
    },
    detached: function () {
    }
  },
  pageLifetimes: {},
  methods: {
    chooseItem(item) {

    },
    goMyIntegral() {
      router.push({ name: 'myIntegral' })
    },
    fetchData() {
      let data = {
        pageNum: 1, pageSize: 30
      };
      return queryProductList(data).then(res => {
        if (res.code === 0) {
          this.setData({ listData: res.data.list, isHasData: true, hasNextPage: res.data.hasNextPage })
        } else {
          console.info("queryProductList 获取商品失败")
          this.setData({ listData: [], isHasData: false })
        }
      })
    }
  }
})
